package cn.zhp.controller;

import cn.zhp.entity.Result;
import cn.zhp.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;


/**
 * 日志类
 */
@RestController
@RequestMapping("manager/syslog")
public class SysLogController {

    @Autowired
    SysLogService service;

    @RequestMapping("")
    public ModelAndView toIndex() {
        return new ModelAndView("/log/log");
    }

    //后台接受map类型必须强制绑定@RequestBody
    @RequestMapping("selectPage/{pageNum}/{pageSize}")
    public Result listPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize, @RequestBody Map<String, Object> params) {
        return new Result(true, "操作成功", service.selectByCondition(params, pageNum, pageSize));
    }

    @RequestMapping("list")
    public Result selectAll() {
        return new Result(true, "操作成功", service.selectAll());
    }

}
